/*
 * Copyright (c) 2016 moondev.cn
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package cn.moondev.moonlog.delegate.mq;

import cn.moondev.moonlog.delegate.spring.SpringContextHolder;
import org.springframework.context.ApplicationContext;


/**
 * 仅供log-core使用<BR>
 * 请注意：此Producer采用<code>ONEWAY</code>方式发送消息到mq，不保证消息的可靠性，请谨慎使用
 * @author scchen
 *
 */
public class ProducerFactory {
	
	public static Producer getProducer() {
		ApplicationContext springContextHolder = SpringContextHolder.getApplicationContext();
        if (springContextHolder == null) {
            throw new RuntimeException("please init spring applicationContext or conf ApplicationContextUtils");
        }
        return (Producer) springContextHolder.getBean("producer");
	}
}
